home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / perl.z / perl
Text File  |  1998-10-30  |  17KB  |  463 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      perl - Practical Extraction and Report Language
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ppppeeeerrrrllll [ ----ssssTTTTuuuuUUUU ]      [ ----hhhhvvvv ] [ ----VVVV[:_c_o_n_f_i_g_v_a_r] ]
  13.           [ ----ccccwwww ] [ ----dddd[:_d_e_b_u_g_g_e_r] ] [ ----DDDD[_n_u_m_b_e_r/_l_i_s_t] ]
  14.           [ ----ppppnnnnaaaa ] [ ----FFFF_p_a_t_t_e_r_n ] [ ----llll[_o_c_t_a_l] ] [ ----0000[_o_c_t_a_l] ]
  15.           [ ----IIII_d_i_r ] [ ----mmmm[----]_m_o_d_u_l_e ] [ ----MMMM[----]'_m_o_d_u_l_e...' ]      [ ----PPPP ]
  16.           [ ----SSSS ]      [ ----xxxx[_d_i_r] ]      [ ----iiii[_e_x_t_e_n_s_i_o_n] ]
  17.           [ ----eeee '_c_o_m_m_a_n_d' ] [ -------- ] [ _p_r_o_g_r_a_m_f_i_l_e ] [ _a_r_g_u_m_e_n_t ]...
  18.  
  19.      For ease of access, the Perl manual has been split up into a number of
  20.      sections:
  21.  
  22.          perl        Perl overview (this section)
  23.          perldelta   Perl changes since previous version
  24.          perlfaq     Perl frequently asked questions
  25.  
  26.          perldata    Perl data structures
  27.          perlsyn     Perl syntax
  28.          perlop      Perl operators and precedence
  29.          perlre      Perl regular expressions
  30.          perlrun     Perl execution and options
  31.          perlfunc    Perl builtin functions
  32.          perlvar     Perl predefined variables
  33.          perlsub     Perl subroutines
  34.          perlmod     Perl modules: how they work
  35.          perlmodlib  Perl modules: how to write and use
  36.          perlform    Perl formats
  37.          perllocale  Perl locale support
  38.  
  39.          perlref     Perl references
  40.          perldsc     Perl data structures intro
  41.          perllol     Perl data structures: lists of lists
  42.          perltoot    Perl OO tutorial
  43.          perlobj     Perl objects
  44.          perltie     Perl objects hidden behind simple variables
  45.          perlbot     Perl OO tricks and examples
  46.          perlipc     Perl interprocess communication
  47.  
  48.          perldebug   Perl debugging
  49.          perldiag    Perl diagnostic messages
  50.          perlsec     Perl security
  51.          perltrap    Perl traps for the unwary
  52.          perlstyle   Perl style guide
  53.  
  54.          perlpod     Perl plain old documentation
  55.          perlbook    Perl book information
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  71.  
  72.  
  73.  
  74.          perlembed   Perl ways to embed perl in your C or C++ application
  75.          perlapio    Perl internal IO abstraction interface
  76.          perlxs      Perl XS application programming interface
  77.          perlxstut   Perl XS tutorial
  78.          perlguts    Perl internal functions for those doing extensions
  79.          perlcall    Perl calling conventions from C
  80.  
  81.      (If you're intending to read these straight through for the first time,
  82.      the suggested order will tend to reduce the number of forward
  83.      references.)
  84.  
  85.      The above manpages are installed in the /_u_s_r/_s_h_a_r_e/_c_a_t_m_a_n/_u__m_a_n/_c_a_t_1/
  86.      directory.
  87.  
  88.      Extensive additional documentation for Perl modules is available.  The
  89.      IRIX configuration of perl places the documentation for the standard
  90.      modules in the /_u_s_r/_s_h_a_r_e/_c_a_t_m_a_n/_p__m_a_n/_c_a_t_3/_p_e_r_l_5/ directory.  The
  91.      documentation for third-party modules will by default be installed into
  92.      the /_u_s_r/_c_a_t_m_a_n/_l_o_c_a_l/_m_a_n_3/_p_e_r_l_5/ directory.  These directories are all
  93.      in the standard IRIX MANPATH.
  94.  
  95.      If something strange has gone wrong with your program and you're not sure
  96.      where you should look for help, try the ----wwww switch first.  It will often
  97.      point out exactly where the trouble is.
  98.  
  99. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  100.      Perl is a language optimized for scanning arbitrary text files,
  101.      extracting information from those text files, and printing reports based
  102.      on that information.  It's also a good language for many system
  103.      management tasks.  The language is intended to be practical (easy to use,
  104.      efficient, complete) rather than beautiful (tiny, elegant, minimal).
  105.  
  106.      Perl combines (in the author's opinion, anyway) some of the best features
  107.      of C, sssseeeedddd, aaaawwwwkkkk, and sssshhhh, so people familiar with those languages should
  108.      have little difficulty with it.  (Language historians will also note some
  109.      vestiges of ccccsssshhhh, Pascal, and even BASIC-PLUS.)  Expression syntax
  110.      corresponds quite closely to C expression syntax.  Unlike most Unix
  111.      utilities, Perl does not arbitrarily limit the size of your data--if
  112.      you've got the memory, Perl can slurp in your whole file as a single
  113.      string.  Recursion is of unlimited depth.  And the tables used by hashes
  114.      (previously called "associative arrays") grow as necessary to prevent
  115.      degraded performance.  Perl uses sophisticated pattern matching
  116.      techniques to scan large amounts of data very quickly.  Although
  117.      optimized for scanning text, Perl can also deal with binary data, and can
  118.      make dbm files look like hashes.  Setuid Perl scripts are safer than C
  119.      programs through a dataflow tracing mechanism which prevents many stupid
  120.      security holes.
  121.  
  122.      If you have a problem that would ordinarily use sssseeeedddd or aaaawwwwkkkk or sssshhhh, but it
  123.      exceeds their capabilities or must run a little faster, and you don't
  124.      want to write the silly thing in C, then Perl may be for you.  There are
  125.      also translators to turn your sssseeeedddd and aaaawwwwkkkk scripts into Perl scripts.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  137.  
  138.  
  139.  
  140.      But wait, there's more...
  141.  
  142.      Perl version 5 is nearly a complete rewrite, and provides the following
  143.      additional benefits:
  144.  
  145.      +o Many usability enhancements
  146.           It is now possible to write much more readable Perl code (even
  147.           within regular expressions).  Formerly cryptic variable names can be
  148.           replaced by mnemonic identifiers.  Error messages are more
  149.           informative, and the optional warnings will catch many of the
  150.           mistakes a novice might make.  This cannot be stressed enough.
  151.           Whenever you get mysterious behavior, try the ----wwww switch!!!  Whenever
  152.           you don't get mysterious behavior, try using ----wwww anyway.
  153.  
  154.      +o Simplified grammar
  155.           The new yacc grammar is one half the size of the old one.  Many of
  156.           the arbitrary grammar rules have been regularized.  The number of
  157.           reserved words has been cut by 2/3.  Despite this, nearly all old
  158.           Perl scripts will continue to work unchanged.
  159.  
  160.      +o Lexical scoping
  161.           Perl variables may now be declared within a lexical scope, like
  162.           "auto" variables in C.  Not only is this more efficient, but it
  163.           contributes to better privacy for "programming in the large".
  164.           Anonymous subroutines exhibit deep binding of lexical variables
  165.           (closures).
  166.  
  167.      +o Arbitrarily nested data structures
  168.           Any scalar value, including any array element, may now contain a
  169.           reference to any other variable or subroutine.  You can easily
  170.           create anonymous variables and subroutines.  Perl manages your
  171.           reference counts for you.
  172.  
  173.      +o Modularity and reusability
  174.           The Perl library is now defined in terms of modules which can be
  175.           easily shared among various packages.  A package may choose to
  176.           import all or a portion of a module's published interface.  Pragmas
  177.           (that is, compiler directives) are defined and used by the same
  178.           mechanism.
  179.  
  180.      +o Object-oriented programming
  181.           A package can function as a class.  Dynamic multiple inheritance and
  182.           virtual methods are supported in a straightforward manner and with
  183.           very little new syntax.  Filehandles may now be treated as objects.
  184.  
  185.      +o Embeddable and Extensible
  186.           Perl may now be embedded easily in your C or C++ application, and
  187.           can either call or be called by your routines through a documented
  188.           interface.  The XS preprocessor is provided to make it easy to glue
  189.           your C or C++ routines into Perl.  Dynamic loading of modules is
  190.           supported, and Perl itself can be made into a dynamic library.
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  203.  
  204.  
  205.  
  206.      +o POSIX compliant
  207.           A major new module is the POSIX module, which provides access to all
  208.           available POSIX routines and definitions, via object classes where
  209.           appropriate.
  210.  
  211.      +o Package constructors and destructors
  212.           The new BEGIN and END blocks provide means to capture control as a
  213.           package is being compiled, and after the program exits.  As a
  214.           degenerate case they work just like awk's BEGIN and END when you use
  215.           the ----pppp or ----nnnn switches.
  216.  
  217.      +o Multiple simultaneous DBM implementations
  218.           A Perl program may now access DBM, NDBM, SDBM, GDBM, and Berkeley DB
  219.           files from the same script simultaneously.  In fact, the old dbmopen
  220.           interface has been generalized to allow any variable to be tied to
  221.           an object class which defines its access methods.
  222.  
  223.      +o Subroutine definitions may now be autoloaded
  224.           In fact, the AUTOLOAD mechanism also allows you to define any
  225.           arbitrary semantics for undefined subroutine calls.  It's not for
  226.           just autoloading.
  227.  
  228.      +o Regular expression enhancements
  229.           You can now specify nongreedy quantifiers.  You can now do grouping
  230.           without creating a backreference.  You can now write regular
  231.           expressions with embedded whitespace and comments for readability.
  232.           A consistent extensibility mechanism has been added that is upwardly
  233.           compatible with all old regular expressions.
  234.  
  235.      +o Innumerable Unbundled Modules
  236.           The Comprehensive Perl Archive Network described in the _p_e_r_l_m_o_d_l_i_b
  237.           manpage contains hundreds of plug-and-play modules full of reusable
  238.           code.  See _h_t_t_p://_w_w_w._p_e_r_l._c_o_m/_C_P_A_N for a site near you.
  239.  
  240.      +o Compilability
  241.           While not yet in full production mode, a working perl-to-C compiler
  242.           does exist.  It can generate portable byte code, simple C, or
  243.           optimized C code.
  244.  
  245.      Okay, that's _d_e_f_i_n_i_t_e_l_y enough hype.
  246.  
  247. EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT
  248.      See the _p_e_r_l_r_u_n manpage.
  249.  
  250. AAAAUUUUTTTTHHHHOOOORRRR
  251.      Larry Wall <_l_a_r_r_y@_w_a_l_l._o_r_g>, with the help of oodles of other folks.
  252.  
  253.      If your Perl success stories and testimonials may be of help to others
  254.      who wish to advocate the use of Perl in their applications, or if you
  255.      wish to simply express your gratitude to Larry and the Perl developers,
  256.      please write to <_p_e_r_l-_t_h_a_n_k_s@_p_e_r_l._o_r_g>.
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  269.  
  270.  
  271.  
  272. FFFFIIIILLLLEEEESSSS
  273.       "/tmp/perl-e$$"        temporary file for -e commands
  274.       "@INC"                 locations of perl libraries
  275.  
  276.  
  277. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  278.       a2p    awk to perl translator
  279.  
  280.       s2p    sed to perl translator
  281.  
  282.  
  283. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  284.      The ----wwww switch produces some lovely diagnostics.
  285.  
  286.      See the _p_e_r_l_d_i_a_g manpage for explanations of all Perl's diagnostics.
  287.  
  288.      Compilation errors will tell you the line number of the error, with an
  289.      indication of the next token or token type that was to be examined.  (In
  290.      the case of a script passed to Perl via ----eeee switches, each ----eeee is counted
  291.      as one line.)
  292.  
  293.      Setuid scripts have additional constraints that can produce error
  294.      messages such as "Insecure dependency".  See the _p_e_r_l_s_e_c manpage.
  295.  
  296.      Did we mention that you should definitely consider using the ----wwww switch?
  297.  
  298. IIIIRRRRIIIIXXXX SSSSPPPPEEEECCCCIIIIFFFFIIIICCCCSSSS
  299.      Perl is compiled with a shared libperl.so, which lives in the /_u_s_r/_l_i_b_3_2
  300.      directory. It is compiled with 5.003 compatibility on.
  301.  
  302.      Perl's standard library installs into /_u_s_r/_s_h_a_r_e/_l_i_b/_p_e_r_l_5/, which may be
  303.      NFS mounted read-only. In that case, and if you wish to install modules
  304.      locally, you should consider moving the /_u_s_r/_s_h_a_r_e/_l_i_b/_p_e_r_l_5/_s_i_t_e__p_e_r_l/
  305.      directory to some place on the local disk, and create a symlink.
  306.  
  307.      Perl is compiled ----nnnn33332222 ----mmmmiiiippppssss3333. If you have any compiled modules from an
  308.      older IRIX release, they are probably compiled ----33332222, and will have to be
  309.      recompiled before they will work. If your modules use libraries that are
  310.      not available in ----nnnn33332222, then you will need a version of perl compiled to
  311.      that ABI. You cannot link or load objects of different ABI. A version of
  312.      perl compiled ----33332222 is available via SGI Freeware (CDROM or various Web
  313.      locations).
  314.  
  315.      Perl is compiled to use ddddrrrraaaannnndddd44448888(((()))) as Perl's rrrraaaannnndddd(((()))) function, instead of
  316.      the standard, weak PRNG.
  317.  
  318. BBBBUUUUGGGGSSSS
  319.      The ----wwww switch is not mandatory.
  320.  
  321.      Perl is at the mercy of your machine's definitions of various operations
  322.      such as type casting, _a_t_o_f(), and floating-point output with _s_p_r_i_n_t_f().
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  335.  
  336.  
  337.  
  338.      If your stdio requires a seek or eof between reads and writes on a
  339.      particular stream, so does Perl.  (This doesn't apply to _s_y_s_r_e_a_d() and
  340.      _s_y_s_w_r_i_t_e().)
  341.  
  342.      While none of the built-in data types have any arbitrary size limits
  343.      (apart from memory size), there are still a few arbitrary limits:  a
  344.      given variable name may not be longer than 255 characters, and no
  345.      component of your PATH may be longer than 255 if you use ----SSSS.  A regular
  346.      expression may not compile to more than 32767 bytes internally.
  347.  
  348.      You may mail your bug reports (be sure to include full configuration
  349.      information as output by the myconfig program in the perl source tree, or
  350.      by perl -V) to <_p_e_r_l_b_u_g@_p_e_r_l._c_o_m>.  If you've succeeded in compiling
  351.      perl, the perlbug script in the utils/ subdirectory can be used to help
  352.      mail in a bug report.
  353.  
  354.      Perl actually stands for Pathologically Eclectic Rubbish Lister, but
  355.      don't tell anyone I said that.
  356.  
  357. NNNNOOOOTTTTEEEESSSS
  358.      The Perl motto is "There's more than one way to do it."  Divining how
  359.      many more is left as an exercise to the reader.
  360.  
  361.      The three principal virtues of a programmer are Laziness, Impatience, and
  362.      Hubris.  See the Camel Book for why.
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.                                                                         PPPPaaaaggggeeee 7777
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.